package cn.cqie.attendance.teacher.controller;

import cn.cqie.attendance.common.util.Page;
import cn.cqie.attendance.common.util.PageBean;
import cn.cqie.attendance.teacher.pojo.TeacherHistoryTask;
import cn.cqie.attendance.teacher.pojo.TeacherScore;
import cn.cqie.attendance.teacher.service.TeacherScoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wqh
 * @date 2021/6/22 14:46
 */
@RestController
@Api(tags = "教师端-综合打分模块")
@RequestMapping("/teacher/score")
public class TeacherScoreController {

    @Autowired
    private TeacherScoreService teacherScoreService;

    @GetMapping("/queryCoursePersonByTeacherId")
    @ApiOperation("查看老师下的个人评分")
    public PageBean<TeacherScore> queryCoursePersonByTeacherId(Integer courseId, Integer courseGroupId, Integer pageNum, Integer pageSize) {
        return teacherScoreService.queryCoursePersonByTeacherId(courseId,courseGroupId,pageNum,pageSize);
    }

    @GetMapping("/queryCourseGroupByTeacherId")
    @ApiOperation("查看老师下的小组评分")
    public PageBean<TeacherScore> queryCourseGroupByTeacherId(Integer courseId, Integer groupId, Integer pageNum, Integer pageSize) {
        return teacherScoreService.queryCourseGroupByTeacherId(courseId,groupId,pageNum,pageSize);
    }

    @GetMapping("/queryCourseGroupDetailByGroupId")
    @ApiOperation("查看老师下的小组评分详情")
    public Page<TeacherScore> queryCourseGroupDetailByGroupId(@RequestParam(value = "groupId")Integer groupId) {
        return teacherScoreService.queryCourseGroupDetailByGroupId(groupId);
    }

    @GetMapping("/queryPersonTaskByStudentId")
    @ApiOperation("查看老师下的个人评分详情")
    public Page<TeacherScore> queryPersonTaskByStudentId(@RequestParam(value = "courseId") Integer courseId,@RequestParam(value = "studentId") Integer studentId) {
        return teacherScoreService.queryPersonTaskByStudentId(courseId,studentId);
    }

    @PostMapping("/updateStudentCourseByStudentId")
    @ApiOperation("老师给个人进行综合打分")
    public Page updateStudentCourseByStudentId(@RequestParam(value = "overAllScore")float overAllScore,@RequestParam(value = "comment") String comment,@RequestParam(value = "courseId") Integer courseId,@RequestParam(value = "studentId") Integer studentId,@RequestParam(value = "responseTeacher")Integer responseTeacher){
        return teacherScoreService.updateStudentCourseByStudentId(overAllScore,comment,courseId,studentId,responseTeacher);
    }

    @GetMapping("/queryHistoryTaskByStudentId")
    @ApiOperation("查看个人历史作业记录")
    public PageBean<TeacherHistoryTask> queryHistoryTaskByStudentId(@RequestParam(value = "studentId")Integer studentId,@RequestParam(value = "courseId") Integer courseId, Integer pageNum, Integer pageSize) {
        return teacherScoreService.queryHistoryTaskByStudentId(studentId,courseId,pageNum,pageSize);
    }

    @GetMapping("/queryHistoryTaskByGroupId")
    @ApiOperation("查看小组历史作业记录")
    public PageBean<TeacherHistoryTask> queryHistoryTaskByGroupId(@RequestParam(value = "groupId")Integer groupId, @RequestParam(value = "courseId") Integer courseId, Integer pageNum, Integer pageSize) {
        return teacherScoreService.queryHistoryTaskByGroupId(groupId,courseId,pageNum,pageSize);
    }

    @PostMapping("/updateStudentCourseByGroupId")
    @ApiOperation("老师对小组进行打分和评论")
    public Page updateStudentCourseByGroupId(@RequestParam(value = "overAllScore")float overAllScore,@RequestParam(value = "comment") String comment,@RequestParam(value = "groupId") Integer groupId,@RequestParam(value = "responseTeacher")Integer responseTeacher) {
        return teacherScoreService.updateStudentCourseByGroupId(overAllScore,comment,groupId,responseTeacher);
    }
}
